/*
Copyright 2025 PerfXLab (Beijing) Technologies Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "OpenSparseBLAS_func.h"
#include "OpenSparseBLAS_type.h"

#define OpenSpB_VECTOR_EXTRACT_CPP(type, T)                                    \
    OpenSpB_info OpenSpB_vector_extract_element(type *x, const OpenSpB_vector v, OpenSpB_index i) \
    {                                                                      \
        return OpenSpB_vector_extract_element_##T(x, v, i);                     \
    }

OpenSpB_VECTOR_EXTRACT_CPP(bool, BOOL);
OpenSpB_VECTOR_EXTRACT_CPP(int8_t, INT8);
OpenSpB_VECTOR_EXTRACT_CPP(int16_t, INT16);
OpenSpB_VECTOR_EXTRACT_CPP(int32_t, INT32);
OpenSpB_VECTOR_EXTRACT_CPP(int64_t, INT64);
OpenSpB_VECTOR_EXTRACT_CPP(uint8_t, UINT8);
OpenSpB_VECTOR_EXTRACT_CPP(uint16_t, UINT16);
OpenSpB_VECTOR_EXTRACT_CPP(uint32_t, UINT32);
OpenSpB_VECTOR_EXTRACT_CPP(uint64_t, UINT64);
OpenSpB_VECTOR_EXTRACT_CPP(float, FP32);
OpenSpB_VECTOR_EXTRACT_CPP(double, FP64);
#undef OpenSpB_VECTOR_EXTRACT_CPP

#define OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(type, T)                                    \
    OpenSpB_info OpenSpB_vector_extract_tuples(OpenSpB_index *I, type * X, OpenSpB_index *p_nvals, const OpenSpB_vector v) \
    {                                                                      \
        return OpenSpB_vector_extract_tuples_##T(I, X, p_nvals, v);                     \
    }

OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(bool, BOOL);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(int8_t, INT8);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(int16_t, INT16);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(int32_t, INT32);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(int64_t, INT64);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(uint8_t, UINT8);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(uint16_t, UINT16);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(uint32_t, UINT32);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(uint64_t, UINT64);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(float, FP32);
OpenSpB_VECTOR_EXTRACT_TUPLES_CPP(double, FP64);
#undef OpenSpB_VECTOR_EXTRACT_TUPLES_CPP

#define OpenSpB_VECTOR_SET_CPP(type, T)                                   \
    OpenSpB_info OpenSpB_vector_set_element(OpenSpB_vector v, type x, OpenSpB_index i) \
    {                                                                 \
        return OpenSpB_vector_set_element_##T(v, x, i);                    \
    }

OpenSpB_VECTOR_SET_CPP(bool, BOOL);
OpenSpB_VECTOR_SET_CPP(int8_t, INT8);
OpenSpB_VECTOR_SET_CPP(int16_t, INT16);
OpenSpB_VECTOR_SET_CPP(int32_t, INT32);
OpenSpB_VECTOR_SET_CPP(int64_t, INT64);
OpenSpB_VECTOR_SET_CPP(uint8_t, UINT8);
OpenSpB_VECTOR_SET_CPP(uint16_t, UINT16);
OpenSpB_VECTOR_SET_CPP(uint32_t, UINT32);
OpenSpB_VECTOR_SET_CPP(uint64_t, UINT64);
OpenSpB_VECTOR_SET_CPP(float, FP32);
OpenSpB_VECTOR_SET_CPP(double, FP64);
#undef OpenSpB_VECTOR_SET_CPP